<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <h2>具名插槽</h2>
      <button @click="slotname = 'before'">btn</button>
      <child>
        <!-- <span>123</span>
        <span>456</span> -->

        <!-- <template v-slot:before>
          <span>123</span>
        </template> -->

        <template #[slotname]>
          <span>456</span>
        </template>

        <!-- <template #default>
          <span>000</span>
        </template> -->
      </child>
    </div>

    <script src="./lib/vue3.js"></script>
    <script>
      const { createApp } = Vue;
      const Child = {
        template: `
          <div>
            <slot name="before"></slot>
            - 这是child子组件 - 
            <slot name="after"></slot>
          </div>
        `,
      };

      const app = createApp({
        data() {
          return {
            slotname: "after",
          };
        },
        components: {
          Child,
        },
      });

      app.mount("#app");
    </script>
  </body>
</html>
